from django.db import models


# Create your models here.
class Publish(models.Model):
    name = models.CharField(max_length=32, unique=True, verbose_name='出版社名')
    addr = models.CharField(max_length=255, verbose_name='地址')
    email = models.EmailField(verbose_name='邮箱')
    desc = models.TextField(verbose_name='简介')

    def __str__(self):
        return f"{self.name} 出版社对象"

    class Meta():
        db_table = "publish"
        verbose_name_plural = "出版社表"


class PublishAdmin(models.Model):
    username = models.CharField(max_length=32, unique=True)
    password = models.CharField(max_length=255)
    publish = models.OneToOneField(to='Publish', on_delete=models.CASCADE, null=True)

    class Meta():
        db_table = 'publish_admin'
        verbose_name_plural = '出版社管理员表'

    def __str__(self):
        return f"{self.username} 出版社管理员对象"
